<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>节流函数</title>
</head>
<body>
    <input type="text">

    <script>
        function Throttle(fn,interval)
        {
            let startTime = 0;
            const _throttle = function(...args)
            {
               let nowTime = Date.now();
               if(interval+startTime-nowTime<=0)
               {
                fn.call(this,...args);
                startTime = nowTime;
               }
            }
            return _throttle;
        }

        let inputEl = document.querySelector("input");
        inputEl.oninput = Throttle(function()
        {console.log(inputEl.value)},3000)
    </script>
</body>
</html>